package com.qf.day10;

import java.util.Arrays;

/**
 * 解析url
 * 写一个方法，返回url中的所有参数的参数名
 * 例如，对于 url = "http://www.baidu.com/s?tn=json&word=onepiece&rn=10"
 * 返回： [tn, word, rn]
 */
public class Homework1 {
    public static void main(String[] args) {
        String url = "https://passport.jd.com/new/login.aspx?ReturnUrl=https%3A%2F%2Fitem.jd.com%2F100005485240.html%3Fbbtf%3D1&czLogin=1";
        String[] nameArr = parseParamNames(url);
        System.out.println(Arrays.toString(nameArr));
    }
    public static String[] parseParamNames(String url) {
        String[] split = url.split("\\?");
        String[] split1 = split[1].split("&");
        String[] split2 = new String[split1.length];
        for (int i = 0; i < split1.length; i++) {
            split2[i]=split1[i].split("=")[0];
        }
        return  split2;
    }

}
